package wnhz.com.business.freeshop.fragment;

import android.os.Build;
import android.os.Bundle;
import android.os.Message;
import android.support.annotation.IdRes;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.CompoundButton;
import android.widget.RadioButton;
import android.widget.RadioGroup;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;
import wnhz.com.business.R;
import wnhz.com.business.base.MyBaseActivity;
import wnhz.com.business.base.MyBaseFragment;
import wnhz.com.business.impl.ActionBarClickListener;
import wnhz.com.business.view.TranslucentActionBarW;

/**
 * Created by Administrator on 2017/9/21 0021.
 * 分类
 */

public class SecondFragment extends MyBaseFragment implements ActionBarClickListener, RadioGroup.OnCheckedChangeListener, CompoundButton.OnCheckedChangeListener {
    @BindView(R.id.action_bar)
    TranslucentActionBarW actionBar;
    @BindView(R.id.rdbn_one)
    RadioButton rdbnOne;
    @BindView(R.id.rdbn_two)
    RadioButton rdbnTwo;
    @BindView(R.id.rdbn_three)
    RadioButton rdbnThree;
    @BindView(R.id.rdbn_four)
    RadioButton rdbnFour;
    @BindView(R.id.rdbn_five)
    RadioButton rdbnFive;
    @BindView(R.id.rdbn_six)
    RadioButton rdbnSix;
    @BindView(R.id.rdbn_seven)
    RadioButton rdbnSeven;
    @BindView(R.id.rdbn_eight)
    RadioButton rdbnEight;
    @BindView(R.id.rdbn_nine)
    RadioButton rdbnNine;
    Unbinder unbinder;


    private MyBaseActivity activity;

    @Override
    protected void handleMsg(Message msg) {

    }

    @Override
    protected View initView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_free_second, container, false);
        return view;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        // TODO: inflate a fragment view
        View rootView = super.onCreateView(inflater, container, savedInstanceState);
        unbinder = ButterKnife.bind(this, rootView);
        activity = (MyBaseActivity) getActivity();
        actionBar.setData(null, 0, null, 0, null, 1, this);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            //沉浸
            activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            //改变状态栏颜色
            activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
            actionBar.setStatusBarHeight(getStatusBarHeight());
        }
        initdata();
        return rootView;
    }

    private void initdata() {
        rdbnOne.setOnCheckedChangeListener(this);
        rdbnTwo.setOnCheckedChangeListener(this);
        rdbnThree.setOnCheckedChangeListener(this);
        rdbnFour.setOnCheckedChangeListener(this);
        rdbnFive.setOnCheckedChangeListener(this);
        rdbnSix.setOnCheckedChangeListener(this);
        rdbnSeven.setOnCheckedChangeListener(this);
        rdbnEight.setOnCheckedChangeListener(this);
        rdbnNine.setOnCheckedChangeListener(this);
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }

    @Override
    public void onLeftClick() {

    }

    @Override
    public void onRightClick() {

    }

    @Override
    public void onEditTextClick() {

    }

    @Override
    public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
        compoundButton.setTextColor(b ? getResources().getColor(R.color.white) : getResources().getColor(R.color.text51));
        compoundButton.setBackgroundColor(b ? getResources().getColor(R.color.province_line_border) : getResources().getColor(R.color.white));
    }

    @Override
    public void onCheckedChanged(RadioGroup radioGroup, @IdRes int i) {

    }
}
